import {
	reactive,
	ref,
	toRefs,
	getCurrentInstance,
	watch
} from "vue"
import {
	onReady,
	onLoad,
	onShow,
	onShareAppMessage
} from '@dcloudio/uni-app'

import store from '@/store/index.js'; //需要引入store

export default function() {
	const {
		proxy
	} = getCurrentInstance()
	const navigationBarTitle = ref('');

	watch(navigationBarTitle, async (val) => {
		uni.setNavigationBarTitle({
			title: val
		});
	})
	const shareAppMessage = reactive({
		title: '1314商城',
		path: '/pages/index/index',
		imageUrl:'/static/logo.jpg'
	});
	const shareApp = (options = {}) => {
		
	}
	onShareAppMessage((res) => {
		console.log('onShareAppMessage');
		if (res.from === 'button') { // 来自页面内分享按钮
			console.log('button', res.target)
		}
		console.log('onShareAppMessage', shareAppMessage.path)
		return shareAppMessage
	})
	// onReady(() => {

	// })
	// onShow(() => {

	// })

	// onShareAppMessage((res) => {
	// 	if (res.from === 'button') { // 来自页面内分享按钮
	// 		console.log('button', res.target)
	// 	}
	// 	console.log('onShareAppMessage', shareAppMessage.path)
	// 	return shareAppMessage
	// })

	return {
		navigationBarTitle,
		shareAppMessage
	}
}